import request from '../utils/request'

export const projectApi = {
  getProjects() {
    return request.get('/projects')
  },

  async createProject(projectData) {
    return request.post('/projects', projectData)
  },

  async getProjectById(id) {
    return request.get(`/projects/${id}`)
  },

  async updateProject(id, projectData) {
    return request.put(`/projects/${id}`, projectData)
  },

  async deleteProject(id) {
    return request.delete(`/projects/${id}`)
  },

  async deployProject(id) {
    return request.post(`/deploy/${id}`)
  },

  async getProjectLogs(id) {
    return request.get(`/deploy/${id}/logs`)
  },

  async getAllDeployments() {
    return request.get('/deploy/logs')
  },

  async testServerConnection(serverConfig) {
    return request.post('/projects/test-connection', { serverConfig })
  },

  async rollbackDeploy(projectId, deployId) {
    return request.post(`/deploy/${projectId}/rollback/${deployId}`);
  }
} 